package jdbctest;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * Created by Administrator on 2017/9/11.
 */
public class InserTest {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //运用数据库方法
        //1.加载驱动
        Class.forName("com.mysql.jdbc.Driver");
        //2.连接数据库
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3307/test","root","123456");
        //3.获得statement
        Statement sta = con.createStatement();
        //4.执行sql（表中插入一条数据）
        String sql = "INSERT INTO hhh VALUES ('g','3','kore','b','a');";
        sta.executeUpdate(sql);/**update insert delete 的SQL执行语句要用executeUpdate()方法*/
        //5.关闭资源
        sta.close();
        con.close();
    }
}
